package com.fanghaoran.notes.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * @Author: win11
 * @Date: 2023/04/22/10:04
 * @Description: 购物车类
 */
public class Cart {
    private int cId;
    private int uId;
    private int pId;
    private String pName;
    private BigDecimal price;
    private int num;
    private BigDecimal count;


    public Cart() {
    }

    public Cart(int cId, int uId, int pId, String pName, BigDecimal price, int num) {
        this.cId = cId;
        this.uId = uId;
        this.pId = pId;
        this.pName = pName;
        this.price = price;
        this.num = num;
    }

    /**
     * 获取
     * @return cId
     */
    public int getCId() {
        return cId;
    }

    /**
     * 设置
     * @param cId 购物车id
     */
    public void setCId(int cId) {
        this.cId = cId;
    }

    /**
     * 获取
     * @return uId
     */
    public int getUId() {
        return uId;
    }

    /**
     * 设置
     * @param uId 用户id
     */
    public void setUId(int uId) {
        this.uId = uId;
    }

    /**
     * 获取
     * @return pId
     */
    public int getPId() {
        return pId;
    }

    /**
     * 设置
     * @param pId 商品id
     */
    public void setPId(int pId) {
        this.pId = pId;
    }

    /**
     * 获取
     * @return pName
     */
    public String getPName() {
        return pName;
    }

    /**
     * 设置
     * @param pName 商品名称
     */
    public void setPName(String pName) {
        this.pName = pName;
    }

    /**
     * 获取
     * @return price
     */
    public BigDecimal getPrice() {
        return price;
    }

    /**
     * 设置
     * @param price 商品价格
     */
    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    /**
     * 获取
     * @return num
     */
    public int getNum() {
        return num;
    }

    /**
     * 设置
     * @param num 商品数量
     */
    public void setNum(int num) {
        this.num = num;
    }

    /**
     * 获取
     * @return count
     */
    public BigDecimal getCount() {
        BigDecimal bigDecimal = new BigDecimal(num);
        return price.multiply(bigDecimal);
    }

    /**
     * 设置
     * @param count 小计(商品价格*数量)
     */
    public void setCount(BigDecimal count) {
        this.count = count;
    }

    @Override
    public String toString() {
        return "Cart{cId = " + cId + ", uId = " + uId + ", pId = " + pId + ", pName = " + pName + ", price = " + price + ", num = " + num + ", count = " + count + "}";
    }
}
